package com.itheima.prize.commons.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.itheima.prize.commons.db.entity.CardUser;
import com.itheima.prize.commons.db.entity.ViewCardUserHit;
import com.itheima.prize.commons.db.service.ViewCardUserHitService;
import com.itheima.prize.commons.db.mapper.ViewCardUserHitMapper;
import com.itheima.prize.commons.utils.ApiResult;

import com.itheima.prize.commons.utils.PageBean;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
* @author shawn
* @description 针对表【view_card_user_hit】的数据库操作Service实现
* @createDate 2023-12-26 11:58:48
*/
@Service
public class ViewCardUserHitServiceImpl extends ServiceImpl<ViewCardUserHitMapper, ViewCardUserHit>
    implements ViewCardUserHitService{

    /**
     * 获取中奖记录
     * @param gameid
     * @param curpage
     * @param limit
     * @param request
     * @return
     */
    @Override
    public ApiResult<PageBean<ViewCardUserHit>> getMyPrize(int gameid, int curpage, int limit, HttpServletRequest request) {
        HttpSession session = request.getSession();
        CardUser user = (CardUser) session.getAttribute("user");
        Integer id = user.getId();
        gameid=id;
        Page<ViewCardUserHit> page = new Page<>(curpage,limit);

        Page<ViewCardUserHit> result = this.page(page, new QueryWrapper<ViewCardUserHit>().eq("userid", gameid));


        PageBean<ViewCardUserHit> pageBean = new PageBean<>(result);

        return new ApiResult<PageBean<ViewCardUserHit>>(1,"成功",pageBean);
    }
}




